package com.tanhua.dubbo.api;

import com.tanhua.domain.mongo.VoicePass;
import com.tanhua.dubbo.api.mongo.VoicePassApi;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;


import java.util.List;

@DubboService
public class VoicePassApiImpl implements VoicePassApi {


    @Autowired
    private MongoTemplate mongoTemplate;

    @Override
    public List<VoicePass> findList(Long userId) {

        Query query = new Query(Criteria.where("userId").is(userId));
        List<VoicePass> voicePassList = mongoTemplate.find(query, VoicePass.class);
        return voicePassList;
    }

    @Override
    public void save(VoicePass voicePass) {
        mongoTemplate.insert(voicePass);
    }
}
